# ==============================================================================
# Build libpappradio and some 'simple' testbed-applications
# ==============================================================================

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

PROJECT( PAPPRADIO )

# update current module path, so we have some FindWhatever.cmake-files at hand

SET( CMAKE_MODULE_PATH 
     "${CMAKE_MODULE_PATH}" 
     "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )

# setup output pathes for all compilers (we need to copy some files to the
# build-directory and at least VS-builds otherwise miss that directory)

IF( MSVC )
	# for the Microsoft-compilers turn off some misleading and wrong(!)
	# warnings about standard-library-code, which are intended to urge you
	# to produce code which is compatible with Microsoft Windows, only...
	SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_CRT_SECURE_NO_WARNINGS")
	SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS")

	# we most probably will use exception-handling in c++ ... why ever this
	# is not fully supported without this flag ... will remain a mystery only
	# known to M$...
	SET( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} /EHsc")
	SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")

	# to turn off Microsoft-Compiler-Extensions use this...
	#SET( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} /Za")
	#SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Za")

	# ==============================================================================
	# Setup output directories so that only *ONE* binary-location is allowed for
        # MSVC
	# ==============================================================================

	SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY         ${CMAKE_BINARY_DIR}/bin )
	SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY         ${CMAKE_BINARY_DIR}/bin )
	SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY         ${CMAKE_BINARY_DIR}/bin )
	SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG   ${CMAKE_BINARY_DIR}/bin )
	SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG   ${CMAKE_BINARY_DIR}/bin )
	SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG   ${CMAKE_BINARY_DIR}/bin )
	SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin )
	SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin )
	SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin )
ENDIF( MSVC )

# build libhidapi (x-plattform-access to HID-devices)
ADD_SUBDIRECTORY    ( "source/hidapi-0.7.0"        )
INCLUDE_DIRECTORIES ( "source/hidapi-0.7.0/hidapi" )

# build the library to acess the hardware
ADD_SUBDIRECTORY    ( "source/libpappradio" )
INCLUDE_DIRECTORIES ( "source/libpappradio" )

# build the testbed-application
ADD_SUBDIRECTORY( "source/testbed-App" )


